
if(!window.num){
    window.num = 0;
}
import { _decorator, Component, Node, Prefab,instantiate,director, random } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = gameInt
 * DateTime = Fri Apr 15 2022 21:15:31 GMT+0800 (中国标准时间)
 * Author = xiaopang125
 * FileBasename = gameInt.ts
 * FileBasenameNoExtension = gameInt
 * URL = db://assets/gameInt.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */
@ccclass('gameInt')
export class gameInt extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;
    @property({type:Prefab})
    star:any= null;
    public findClor='';
    @property({type:Node})
    findNode:any= null;


    start () {
        // [3]
        // this.node.removeAllChildren();
        let scene = director.getScene();
        let temNode=null;
        let findNum=Math.floor(Math.random()*49);
        for (let index = 0; index < 49; index++) {
            // const element = array[index];

            let node = instantiate(this.star);
            node.parent = this.node;
            if(index==findNum){
                temNode=node;

            }
            // console.log(node.getComponent("Star").starClor);
            
            node.setPosition(100*(index%7)-300, Math.floor(index/7)*(-100)+500,0);
        }

        setTimeout(() => {
           console.log(temNode.getComponent("Star").starClor);
           this.findClor=temNode.getComponent("Star").starClor;
           this.findNode.getComponent("findNode").drawObj(temNode.getComponent("Star").starClor);

        }, 100);
       

    }

    // update (deltaTime: number) {
    //     // [4]
    // }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
